/*   1:    */ package org.intellij.lang.regexp;
/*   2:    */ 
/*   3:    */

import com.intellij.lang.injection.InjectedLanguageManager;
import com.intellij.openapi.util.ClassExtension;
import com.intellij.psi.PsiComment;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiLanguageInjectionHost;
import org.intellij.lang.regexp.psi.RegExpChar;
import org.intellij.lang.regexp.psi.RegExpGroup;
import org.intellij.lang.regexp.psi.RegExpPyCondRef;
import org.intellij.lang.regexp.psi.RegExpQuantifier;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */ 
/*  15:    */ public final class RegExpLanguageHosts
/*  16:    */   extends ClassExtension<RegExpLanguageHost>
/*  17:    */ {
/*  18: 34 */   private static final RegExpLanguageHosts a = new RegExpLanguageHosts();
/*  19:    */   private final DefaultRegExpPropertiesProvider b;
/*  20:    */   
/*  21:    */   public static RegExpLanguageHosts getInstance()
/*  22:    */   {
/*  23: 38 */     return a;
/*  24:    */   }
/*  25:    */   
/*  26:    */   private RegExpLanguageHosts()
/*  27:    */   {
/*  28: 42 */     super("com.intellij.regExpLanguageHost");
/*  29: 43 */     this.b = DefaultRegExpPropertiesProvider.getInstance();
/*  30:    */   }
/*  31:    */   
/*  32:    */   @Nullable
/*  33:    */   private static RegExpLanguageHost a(@Nullable PsiElement paramPsiElement)
/*  34:    */   {
/*  35: 48 */     if (paramPsiElement == null) {
/*  36: 49 */       return null;
/*  37:    */     }
/*  38: 51 */     PsiLanguageInjectionHost localPsiLanguageInjectionHost = InjectedLanguageManager.getInstance(paramPsiElement.getProject()).getInjectionHost(paramPsiElement);
/*  39: 52 */     if ((localPsiLanguageInjectionHost instanceof RegExpLanguageHost)) {
/*  40: 53 */       return (RegExpLanguageHost)localPsiLanguageInjectionHost;
/*  41:    */     }
/*  42: 55 */     if (localPsiLanguageInjectionHost != null) {
/*  43: 56 */       return (RegExpLanguageHost)a.forClass(localPsiLanguageInjectionHost.getClass());
/*  44:    */     }
/*  45: 58 */     return null;
/*  46:    */   }
/*  47:    */   
/*  48:    */   public boolean isRedundantEscape(@NotNull RegExpChar paramRegExpChar, @NotNull String paramString)
/*  49:    */   {
/*  50: 62 */     if (paramRegExpChar == null) {
/*  51: 62 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/RegExpLanguageHosts", "isRedundantEscape" }));
/*  52:    */     }
/*  53: 62 */     if (paramString == null) {
/*  54: 62 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/intellij/lang/regexp/RegExpLanguageHosts", "isRedundantEscape" }));
/*  55:    */     }
/*  56: 62 */     if (paramString.length() <= 1) {
/*  57: 63 */       return false;
/*  58:    */     }
/*  59: 65 */     RegExpLanguageHost localRegExpLanguageHost = a(paramRegExpChar);
/*  60: 66 */     if (localRegExpLanguageHost != null)
/*  61:    */     {
/*  62: 67 */       char c = paramString.charAt(1);
/*  63: 68 */       boolean bool = localRegExpLanguageHost.characterNeedsEscaping(c);
/*  64: 69 */       return !bool;
/*  65:    */     }
/*  66: 72 */     return (!"\\]".equals(paramString)) && (!"\\}".equals(paramString));
/*  67:    */   }
/*  68:    */   
/*  69:    */   public boolean supportsNamedGroupSyntax(@Nullable RegExpGroup paramRegExpGroup)
/*  70:    */   {
/*  71: 77 */     RegExpLanguageHost localRegExpLanguageHost = a(paramRegExpGroup);
/*  72: 78 */     return (localRegExpLanguageHost != null) && (localRegExpLanguageHost.supportsNamedGroupSyntax(paramRegExpGroup));
/*  73:    */   }
/*  74:    */   
/*  75:    */   public boolean supportsPerl5EmbeddedComments(@Nullable PsiComment paramPsiComment)
/*  76:    */   {
/*  77: 82 */     RegExpLanguageHost localRegExpLanguageHost = a(paramPsiComment);
/*  78: 83 */     return (localRegExpLanguageHost != null) && (localRegExpLanguageHost.supportsPerl5EmbeddedComments());
/*  79:    */   }
/*  80:    */   
/*  81:    */   public boolean supportsPythonConditionalRefs(@Nullable RegExpPyCondRef paramRegExpPyCondRef)
/*  82:    */   {
/*  83: 87 */     RegExpLanguageHost localRegExpLanguageHost = a(paramRegExpPyCondRef);
/*  84: 88 */     return (localRegExpLanguageHost != null) && (localRegExpLanguageHost.supportsPythonConditionalRefs());
/*  85:    */   }
/*  86:    */   
/*  87:    */   public boolean supportsPossessiveQuantifiers(@Nullable RegExpQuantifier paramRegExpQuantifier)
/*  88:    */   {
/*  89: 92 */     RegExpLanguageHost localRegExpLanguageHost = a(paramRegExpQuantifier);
/*  90: 93 */     return (localRegExpLanguageHost == null) || (localRegExpLanguageHost.supportsPossessiveQuantifiers());
/*  91:    */   }
/*  92:    */   
/*  93:    */   public boolean isValidCategory(@NotNull PsiElement paramPsiElement, @NotNull String paramString)
/*  94:    */   {
/*  95: 97 */     if (paramPsiElement == null) {
/*  96: 97 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/RegExpLanguageHosts", "isValidCategory" }));
/*  97:    */     }
/*  98: 97 */     if (paramString == null) {
/*  99: 97 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "1", "org/intellij/lang/regexp/RegExpLanguageHosts", "isValidCategory" }));
/* 100:    */     }
/* 101: 97 */     RegExpLanguageHost localRegExpLanguageHost = a(paramPsiElement);
/* 102: 98 */     return localRegExpLanguageHost != null ? localRegExpLanguageHost.isValidCategory(paramString) : this.b.isValidCategory(paramString);
/* 103:    */   }
/* 104:    */   
/* 105:    */   @NotNull
/* 106:    */   public String[][] getAllKnownProperties(@NotNull PsiElement paramPsiElement)
/* 107:    */   {
/* 108:103 */     if (paramPsiElement == null) {
/* 109:103 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/RegExpLanguageHosts", "getAllKnownProperties" }));
/* 110:    */     }
/* 111:103 */     RegExpLanguageHost localRegExpLanguageHost = a(paramPsiElement); String[][] 
/* 112:104 */       tmp65_62 = (localRegExpLanguageHost != null ? localRegExpLanguageHost.getAllKnownProperties() : this.b.getAllKnownProperties());
/* 113:104 */     if (tmp65_62 == null) {
/* 114:104 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/RegExpLanguageHosts", "getAllKnownProperties" }));
/* 115:    */     }
/* 116:104 */     return tmp65_62;
/* 117:    */   }
/* 118:    */   
/* 119:    */   @Nullable
/* 120:    */   String getPropertyDescription(@NotNull PsiElement paramPsiElement, @Nullable String paramString)
/* 121:    */   {
/* 122:109 */     if (paramPsiElement == null) {
/* 123:109 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/RegExpLanguageHosts", "getPropertyDescription" }));
/* 124:    */     }
/* 125:109 */     RegExpLanguageHost localRegExpLanguageHost = a(paramPsiElement);
/* 126:110 */     return localRegExpLanguageHost != null ? localRegExpLanguageHost.getPropertyDescription(paramString) : this.b.getPropertyDescription(paramString);
/* 127:    */   }
/* 128:    */   
/* 129:    */   @NotNull
/* 130:    */   String[][] getKnownCharacterClasses(@NotNull PsiElement paramPsiElement)
/* 131:    */   {
/* 132:115 */     if (paramPsiElement == null) {
/* 133:115 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/RegExpLanguageHosts", "getKnownCharacterClasses" }));
/* 134:    */     }
/* 135:115 */     RegExpLanguageHost localRegExpLanguageHost = a(paramPsiElement); String[][] 
/* 136:116 */       tmp65_62 = (localRegExpLanguageHost != null ? localRegExpLanguageHost.getKnownCharacterClasses() : this.b.getKnownCharacterClasses());
/* 137:116 */     if (tmp65_62 == null) {
/* 138:116 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/RegExpLanguageHosts", "getKnownCharacterClasses" }));
/* 139:    */     }
/* 140:116 */     return tmp65_62;
/* 141:    */   }
/* 142:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.lang.regexp.RegExpLanguageHosts

 * JD-Core Version:    0.7.0.1

 */